package com.indusfo.spc.controller;

import com.indusfo.spc.aspect.SystemControllerLog;
import com.indusfo.spc.pojo.Bldc;
import com.indusfo.spc.pojo.Blxx;
import com.indusfo.spc.pojo.BlxxPro;
import com.indusfo.spc.service.BlxxService;
import com.indusfo.spc.vo.JSONObject;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;

import javax.annotation.Resource;

/**
 * @ProjectName: IEIS2-COM
 * @Package: com.indusfo.spc.controller
 * @ClassName: BlxxController
 * @Author: 熊冰
 * @Description: 不良现象 视图层
 * @Date: 2019/8/20 16:00
 * @Version: 1.0
 */

@Controller
@RequestMapping("/blxx")
public class BlxxController {

    /**
     * 注入service
     */

    @Resource
    BlxxService blxxService;
    //新增
    @RequestMapping(value="insertBlxx")
    @ResponseBody
    public JSONObject insertBlxx(Blxx blxx){
        blxx.setBadphenoId(null);
        JSONObject json = blxxService.insertOrUpdateBlxx(blxx) ;
        return json;

    }
    //删除
    @RequestMapping(value="delBlxx")
    @ResponseBody
    public JSONObject delBlxx(Long[] ids){
        Integer   dataState = 2;
        JSONObject json = blxxService.deleteBlxx(ids,dataState);
        return json;

    }
    //修改
    @RequestMapping(value="updateBlxx")
    @ResponseBody
    public JSONObject updateBlxx(Blxx blxx){
        JSONObject json = blxxService.insertOrUpdateBlxx(blxx) ;
        return json;

    }
    //查询
    @RequestMapping(value="queryBlxx")
    @ResponseBody
    public JSONObject queryBlxx(Blxx blxx){
        JSONObject json = blxxService.listBlxx(blxx);
        return json;
    }
    //停用
    @RequestMapping(value="stopBlxx")
    @ResponseBody
    public JSONObject stopBlxx(Long[] ids){
        Integer   dataState = 3;
        JSONObject json = blxxService.deleteBlxx(ids,dataState);
        return json;

    }
    //启用
    @RequestMapping(value="startBlxx")
    @ResponseBody
    public JSONObject startBlxx(Long[] ids){
        Integer   dataState = 1;
        JSONObject json = blxxService.deleteBlxx(ids,dataState);
        return json;

    }


    //添加不良原因关联
    @RequestMapping(value="insertBlxxBlyy")
    @ResponseBody
    public JSONObject insertBlxxBlyy(Long[] ids,Integer blxxId){
        JSONObject json = blxxService.insertBlxxBlyy(ids,blxxId);
        return json;

    }
    //删除不良原因关联
    @RequestMapping(value="delBlxxBlyy")
    @ResponseBody
    public JSONObject delBlxxBlyy(Long[] ids,Integer blxxId){
        JSONObject json = blxxService.delBlxxBlyy(ids,blxxId);
        return json;

    }
    //添加不良对策关联
    @RequestMapping(value="insertBlxxBldc")
    @ResponseBody
    public JSONObject insertBlxxBldc(Long[] ids,Integer blxxId){
        JSONObject json = blxxService.insertBlxxBldc(ids,blxxId);
        return json;

    }
    //删除不良对策关联
    @RequestMapping(value="delBlxxBldc")
    @ResponseBody
    public JSONObject delBlxxBldc(Long[] ids,Integer blxxId){
        JSONObject json = blxxService.delBlxxBldc(ids,blxxId);
        return json;

    }


    //查询不良原因
    @RequestMapping(value="selectBlxxBlyy")
    @ResponseBody
    public JSONObject selectBlxxBlyy(Blxx blxx){
        JSONObject json = blxxService.selectBlxxBlyy(blxx);
        return json;

    }

    //查询不良对策
    @RequestMapping(value="selectBlxxBldc")
    @ResponseBody
    public JSONObject selectBlxxBldc(Blxx blxx){
        JSONObject json = blxxService.selectBlxxBldc(blxx);
        return json;

    }
    //全查不良对策
    @RequestMapping(value="queryBldc")
    @SystemControllerLog(description="查询不良对策")
    @ResponseBody
    public JSONObject queryBldc(Blxx blxx) {

        JSONObject json = blxxService.queryBldc(blxx);
        return json;

    }
    //全查不良原因
    @RequestMapping(value="queryBlyy")
    @SystemControllerLog(description="查询不良对策")
    @ResponseBody
    public JSONObject queryBlyy(Blxx blxx) {

        JSONObject json = blxxService.queryBlyy(blxx);
        return json;

    }

    /**
     * @Date 2019/10/23 10:10
     * @Author wamgq
     * 查询不良工序
     */
    @RequestMapping(value="queryPro")
    @ResponseBody
    public JSONObject queryPro(BlxxPro blxxPro){
        JSONObject json = blxxService.queryPro(blxxPro);
        return json;

    }

    /**
     * @Date 2019/10/23 10:10
     * @Author wamgq
     * 新增不良工序
     */
    @RequestMapping(value="insertPro")
    @ResponseBody
    public JSONObject insertPro(Long[] ids,Integer blxxId){
        JSONObject json = blxxService.insertPro(ids,blxxId);
        return json;

    }

    /**
     * @Date 2019/10/23 10:10
     * @Author wamgq
     * 删除不良工序
     */
    @RequestMapping(value="delPro")
    @ResponseBody
    public JSONObject delPro(Long[] ids){
        JSONObject json = blxxService.delPro(ids);
        return json;

    }
}
